local ClientOHOH = _G.ClientOHOH;

local M = ClientOHOH.class.new(script, ClientOHOH.files.OHOHOLYBUIBase());
local CommonOHOH =_G.CommonOHOH
local CallBackManager = ClientOHOH.load.CallBackManager();
local BtnHelper = ClientOHOH.load.BtnHelper();
local LanguageHelper=_G.LanguageHelper 
local TweenHelper = ClientOHOH.load.TweenHelper();
local UIManager = ClientOHOH.load.UIManager();
function InitInsts(ui)
	ui.insts = {};
	ui.insts.list ="ctrl.list"
    ui.insts.close = "ctrl.close"
    ui.insts.group = "ctrl.group"
end

local groupStr = {
	cell = "ctrl.cell"
}

local cellStr = {
    rank = "ctrl.rank",
    rankIcon = "ctrl.rankIcon",
    val = "ctrl.val"
}

function M.new(...)
	return M(...);
end;
function M.ctor(self)
	InitInsts(self)
	M.super.ctor(self, ClientOHOH:GetPath_Loop("ReplicatedStorage.Resource.UI.PVPPopUpGui"));
	self.insts.group.Visible = false
	self.groupList = {}
    self:AddConnect()
end;

function M.AddConnect(self)
	CallBackManager:AddRbxConnect(self,self.insts.close.Activated,function()
		UIManager.ui_list.PVPPopUpGui:Hide()
	end)
	
end


--创建能容纳三个cell的group
function M.CreateGroup(self)
	self.insts.group:Clone()
	local groupObj = self.insts.group:Clone()
	local group = self:InitUiInst2(groupObj,groupStr)
	self:InitUiObj(groupObj)
	groupObj.Parent = self.insts.list
	groupObj.Visible = true
	group.cell.Visible =false
	group.Obj = groupObj
	return group
end


--创建cell
function M.CreateCell(self,data,group)
	local cellObj = group.cell:Clone()
	local cell = self:InitUiInst2(cellObj,cellStr)
	self:InitUiObj(cellObj)
	cellObj.Parent = group.Obj
	cellObj.Visible = true
	cell.rank.Text = data.name
	cell.rankIcon.Image = data.icon
	cell.val.Text = data.range
end
-----------接口-----------
--填充面板
function M.Full(self,data)
	for index, value in pairs(data) do
		if index%3==1 then
			table.insert(self.groupList,self:CreateGroup())
		end
		self:CreateCell(value,self.groupList[math.floor((index-1)/3+1)])
	end
end


function M.dtor(self)
	M.super.dtor(self);
end;




return M
